<?php 
require_once 'init.php';
require_once 'ckLogin.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'config.php';
require_once 'dbClasses'.DIRECTORY_SEPARATOR.'dbConn.php';
$db = new dbConn();
//定义表名
define("TABLENAME","zz_extend_zhuanti");
define("TABLENAME1","zz_extend_zhuanti_key");
define("TABLENAME2","fanhuan_category");
//提交处理
if(strtoupper($_SERVER['REQUEST_METHOD'])=='POST'){
    if($_GET['act']=="goodsUpdate"){ //var_dump($_POST);
        if (isset($_POST['contentID'])) {
            $updateArray = array();
            if(!empty($_POST['goodsUrl'])) $updateArray[] = "`goodsUrl` = '{$_POST['goodsUrl']}'";
            if(!empty($_POST['title'])) $updateArray[] = "`title` = '{$_POST['title']}'";
            if(!empty($_POST['pic_1'])) $updateArray[] = "`picture` = '{$_POST['pic_1']}'";
            if(!empty($_POST['originalPrice'])) $updateArray[] = "`originalPrice` = {$_POST['originalPrice']}";
            if(!empty($_POST['currentPrice'])) $updateArray[] = "`currentPrice` = {$_POST['currentPrice']}";
            if(!empty($_POST['sort'])) $updateArray[] = "`sort` = {$_POST['sort']}";
            //var_dump(implode(',', $updateArray));
            $db->sql="UPDATE ".TABLENAME." SET ".implode(',', $updateArray)." WHERE id={$_POST['contentID']}";
            $db->doExecute();
        }
    }
    if($_GET['act']=="insertZhuanti"){
        //zhuantiTitle startTime endTime
        $db->sql="INSERT INTO `".TABLENAME1."` (`title`,`startTime`,`endTime`,`createTime`) VALUES('{$_POST['zhuantiTitle']}','{$_POST['startTime']}','{$_POST['endTime']}',UNIX_TIMESTAMP())";
        $db->doExecute();
    }
    if($_GET['act']=="delZhuanti"){
        //zhuantiTitle startTime endTime
        $db->sql="DELETE FROM `".TABLENAME1."` WHERE id = {$_POST['zhuantiID']}";
        $db->doExecute();
    }
}
//条件
$where = "WHERE p.`status`!=0 AND p.`isDel`!=1 ";
if(!empty($_GET['goodsid']) || !empty($_GET['zhuantiID'])){
	if(!empty($_GET['goodsid'])) $where.= "AND p.goodsID='".$_GET['goodsid']."' ";
	if(!empty($_GET['zhuantiID'])) $where.= "AND p.zhuantiID='".$_GET['zhuantiID']."' ";
}
//总条数
$db->sql="SELECT count(p.id) FROM ".TABLENAME." p LEFT JOIN ".TABLENAME1." k ON p.zhuantiID = k.id ".$where;
$count= $db->doResultOne();
//分页
$page = $_GET['page'] ? $_GET['page'] : 1;
$pagesize = $_GET['pagesize']?$_GET['pagesize']:50;
$pageInfo = page($count, $pagesize, $page);
$maxPage = $pageInfo['maxPage'];
$start = $pageInfo['start'];
$pages = $pageInfo['pages'];

$db->sql="SELECT p.*,k.title ktitle FROM ".TABLENAME." p LEFT JOIN ".TABLENAME1." k ON p.zhuantiID = k.id ".$where." ORDER BY p.publishDate DESC,p.sort ASC LIMIT ".$start.",".$pagesize;
$pictures = $db->doResultList2();

//专题
$db->sql="SELECT * FROM `".TABLENAME1."`";
$zhuantiList = $db->doResultList2();
//var_dump($pictures);die();
//url
$url= "?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid']."&sort=".$_GET['sort'];
$url2="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid']."&cateid=".$_GET['cateid'];
$url3="?startTime=".$_GET['startTime']."&endTime=".$_GET['endTime']."&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];
$url4="?&updater=".$_GET['updater']."&pagesize=".$_GET['pagesize']."&goodsid=".$_GET['goodsid'];

//分页
function page($total,$size,$page){
	//最大页数
	if($total%$size==0){
		$maxPage = $total/$size;
	}else{
		$maxPage = (int)($total/$size)+1;
	}
	//开始条数
	$start = ($page-1)*$size;
	//分页
	if($maxPage>=5){
		if($page<=2){
			$pages=array(1,2,3,4,5);
		}elseif($page>=($maxPage-1)){
			$pages=array($maxPage-4,$maxPage-3,$maxPage-2,$maxPage-1,$maxPage);
		}else{
			$pages=array($page-2,$page-1,$page,$page+1,$page+2);
		}
	}else{
		for($i=1;$i<=$maxPage;$i++){
			$pages[]=$i;
		}
	}
	if($page<=1){$previous=1;}else{$previous=$page-1;} 
	if($page>=$maxPage) {$next = $maxPage;}else{ $next = $page+1;}
	return array('maxPage'=>$maxPage,'start'=>$start,'pages'=>$pages,'previous'=>$previous,'next'=>$next);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simpla Admin</title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="resources/css/reset.css" type="text/css"
	media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="resources/css/main.css" type="text/css"
	media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="resources/css/invalid.css" type="text/css"
	media="screen" />
<style type="text/css">
select {padding: 4px;background: #fff;border: 1px solid #d5d5d5; color: #333;-webkit-border-radius: 4px;border-radius: 4px;}
</style>
<!-- Colour Schemes
		Default colour scheme is green. Uncomment prefered stylesheet to use it.
		<link rel="stylesheet" href="resources/css/blue.css" type="text/css" media="screen" />
		<link rel="stylesheet" href="resources/css/red.css" type="text/css" media="screen" />  
		-->
<!-- Internet Explorer Fixes Stylesheet -->
<!--[if lte IE 7]>
			<link rel="stylesheet" href="resources/css/ie.css" type="text/css" media="screen" />
		<![endif]-->
<!--                       Javascripts                       -->
<!-- jQuery -->
<script type="text/javascript" src="resources/scripts/jquery-1.7.2.min.js"></script>

<script type="text/javascript">

$(function($) {
	/* $.getJSON("http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id=2,1&callback=?", function(data){
		//alert(data.Msg+data.Code);
		var obj = jQuery.parseJSON(data.Msg);
		$.each(obj, function(i,item){
			alert(item.Count);
		}); 
	}); */
	/* 
	$.ajax({
		   type: "GET",
		   url: "http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id=2,1",
		   data: "",
		   dataType: "json",
		   success: function(data){
			   alert(data.Count);
			   
		   }
	});
	 */
	$(".issupergoods").change(function(){
		var id = $(this).parents("tr").data("id");
		//alert(goodsid);
		if($(this).is(":checked")) var val = 1; else var val = 0;
		$.ajax({
			type: "GET",
			url: "youpinAjax.php",
			data: "id="+id+"&act=changeother&table=<?php echo TABLENAME;?>&col=isSuperGoods&val="+val,
			dataType: "html",
			success: function(rs){
				if(rs==1) alert('修改成功 └(^o^)┘');
				else alert('修改失败 ╮(╯3╰)╭');
			}
		});
	});
	$(".isonlytoday").change(function(){
		var id = $(this).parents("tr").data("id");
		//alert(goodsid);
		if($(this).is(":checked")) var val = 1; else var val = 0;
		$.ajax({
			type: "GET",
			url: "youpinAjax.php",
			data: "id="+id+"&act=changeother&table=<?php echo TABLENAME;?>&col=isOnlyToday&val="+val,
			dataType: "html",
			success: function(rs){
				if(rs==1) alert('修改成功 └(^o^)┘');
				else alert('修改失败 ╮(╯3╰)╭');
			}
		});
	});
	$(".editbutton").click(function(){
		$("#pic_id").val($(this).attr('id'));
		//获取描述
		$.ajax({
			   type: "GET",
			   url: "getDesc.php?table=<?php echo TABLENAME;?>",
			   data: "id="+$(this).attr('id'),
			   dataType: "json",
			   success: function(date){
				   $("#description").html(date.desc);
				   $("#title").val(date.title);
				   $("#goodsUrl").val(date.goodsUrl);
				   $("#contentID").val(date.id);
				   $("#originalPrice").val(date.originalPrice); //
				   $("#currentPrice").val(date.currentPrice);
				   $("#sort").val(date.sort);
				   $("#publishDate").val(date.publishDate);
				   $("#pic_1").val(date.picture);
				   $("#message_click").click();
			   }
		});
		
	});
	//删除商品
	$(".delbutton").click(function(){
		var id = $(this).data("id");
		//alert(id);return false;
		if(confirm("是否删除该商品！")){
			//获取描述
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "id="+id+"&act=del&table=<?php echo TABLENAME;?>",
				dataType: "html",
				success: function(date){
					//alert(date);
					
				}
			});
			$(this).parents("tr").hide();
			
		}
	});
	//商品上下架
	$(".isSalebutton").click(function(){
		var _this = $(this);
		var id = _this.data("id");
		var status = _this.data("status");
		if(status==1) {var word = "是否下架该商品？";}
		if(status==2) {var word = "是否上架该商品？";}
		//alert(id);return false;
		if(confirm(word)){
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "id="+id+"&act=isSale&table=<?php echo TABLENAME;?>",
				dataType: "html",
				success: function(rs){
					if(rs==1) {_this.text("上架中");alert("上架成功！！");};
					if(rs==2) {_this.text("下架中");alert("下架成功！！");};
					_this.data("status",rs);
				}
			});
		}
	});
	//多数据操作
	$(".xiugai").click(function(){
		//alert($("#caozuo option:selected").val());
			var text="";  
	        $("input[name=picSel]").each(function() {  
	            if ($(this).attr("checked")) {  
	                text += ","+$(this).val();  
	            }  
	        });
	        //alert(text);
	        window.location.replace('moreEdit.php?ids='+text);
		
	});
	//导出
	$("#download").click(function(){
		/* var startTime = $('#startTime').val();
		var endTime   = $('#endTime').val();
		var updater = $("#updater").val();
		//var pagesize = $("#pagesize").val();
		var cateid = $("#cateid").val();
	    
		$("input[name='starttime_d']").val(startTime);
		$("input[name='endtime_d']").val(endTime);
		$("input[name='cateid_d']").val(cateid);
		$("input[name='updater_d']").val(updater); */

		var ids = $("textarea[name='ids']").val();
		var totalnum = $("#totalNum").val();
		/* $.getJSON('http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='+ids+'&callback=?', function(data){
		    //alert(111);
			//alert(data.Msg+data.Code);
			var obj = jQuery.parseJSON(data.Msg);
			$("textarea[name='idsclick']").val(data.Msg);
			//$.each(obj, function(i,item){
			//	$("tr[goodsid='"+item.ProductId+"']").children(".clickNum").text(item.Count);
			//});
		}); */
		//alert(ids);
		var ii = 0;
		var idsjson = jQuery.parseJSON(ids);
		$.each( idsjson, function(i, n){
		    //alert( n.publishDate );
			$.getJSON("http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id="+n.ids+"&starttime="+n.publishDate+"&callback=?", function(data){
				ii++;
				$("textarea[name='idsclick']").val($("textarea[name='idsclick']").val()+"___"+data.Msg);
				if(totalnum==ii) $("#formForDownload").submit();
			});
		});
		//$("#formForDownload").submit();
		
	});
	//批量删除
	$(".piliangshanchu").click(function(){
		if(confirm("是否删除这些商品！")){
			var ids='';
			$("input[name=picSel]:checked").each(function() {
				ids+=$(this).val()+',';
				$(this).parents("tr").remove();
			});
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "ids="+ids+"&act=piliangshanchu&table=<?php echo TABLENAME;?>",
				dataType: "html",
				success: function(date){
					//alert(date);
					
				}
			});
			//alert(ids);
		}
	});
    //批量设置专题
    $(".piliangSetZhuanTi").click(function(){
        var __zhuantiID = $("#SetZhuantiID").val();
        if(!__zhuantiID){
            alert("请选择专题！");
            return false;
        }
		if(confirm("是否设置商品为该专题！")){
			var ids='';
			var checkinputELe = $("input[name=picSel]:checked");
			checkinputELe.each(function() {
				ids+=$(this).val()+',';
				//$(this).parents("tr").remove();
			});
			$.ajax({
				type: "GET",
				url: "youpinAjax.php",
				data: "ids="+ids+"&act=piliangSetZhuanTi&zhuantiID="+__zhuantiID+"&table=<?php echo TABLENAME;?>",
				dataType: "json",
				success: function(data){
					if(data.ret==1){
    					checkinputELe.each(function() {
    						$(this).parents("tr").children(".tdForZhuanTi").text(data.title);;
    					});
					}
				}
			});
			//alert(ids);
		}
	});
	//添加专题
	$(".addZhuanti").click(function(){
		$("#addZhuantiForm").show();
		$("#delZhuantiForm").hide();
	});
	//删除专题
	$(".delZhuanti").click(function(){
		$("#addZhuantiForm").hide();
		$("#delZhuantiForm").show();
	});
	//
	$("#addZhuantiForm").submit(function(){
		//alert(222);
		//zhuantiTitle startTime endTime
	    if(!$("#zhuantiTitle").val() || !$("#startTime3").val() || !$("#endTime3").val()){
	        alert("不能为空！！！");
	        return false;
		}	    
	});
	//
	$("#delZhuantiForm").submit(function(){
		//delZhuantiForm
    		if(!$("#zhuantiIDforDel").val()){
    			alert("不能为空！！！");
    	        return false;
    		}else{
    			if(confirm("是否将此专题删除?")){
    			    return true;
        		}else{
        		    return false;
            	}
        	}
	});
});

</script>

<!-- jQuery Configuration -->
<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
<!-- jQuery my97datepicker -->
<script type="text/javascript" src="resources/scripts/My97DatePicker/WdatePicker.js"></script>
<!-- jQuery colorbox -->
<link rel="stylesheet" href="resources/css/colorbox.css" />
<script src="resources/scripts/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
$(function($) {
	$(".group-pic").colorbox({rel:'group-pic',width:"50%", height:"75%"});
});
</script>
</head>
<body>
	<div id="body-wrapper">
	<?php if ($noAccess==1 || $noAccess==2):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，日期出错，该商品在这<span style="color: red;"><?php if ($noAccess==1) echo '之前';if ($noAccess==2) echo '之后';?></span>的15天已经上架。
			</div>
		</div>
	<?php endif;?>
	<?php if ($noAccess2==1):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，已被其他责任编辑选用。
			</div>
		</div>
	<?php endif;?>
	<?php if ($publishDateError):?>
		<div class="notification error png_bg">
			<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
			<div>
				修改失败，只能把时间改到今天或者之后，不能改到之前！
			</div>
		</div>
	<?php endif;?>
		<!-- Wrapper for the radial gradient background -->
		<a href="#messages" rel="modal" id="message_click"></a>
		<div id="messages" style="display: none;">
			<!-- Messages are shown when a link with these attributes are clicked: href="#messages" rel="modal"  -->

			<p style="">
				<strong>简短描述输入及修改</strong>
			</p>
			<form action="?act=goodsUpdate" method="post" >
				<fieldset>
					地址：
					<input class="text-input " type="text" id="goodsUrl" name="goodsUrl" style="width: 310px;"/><br />
					名称：
					<input class="text-input " type="text" id="title" name="title" style="width: 310px;"/><br />
					图片：
					<input class="text-input " type="text" id="pic_1" name="pic_1" style="width: 310px;"/><br />
					原价：
					<input class="text-input " type="text" id="originalPrice" name="originalPrice" style="width: 60px;"/>
					现价：
					<input class="text-input " type="text" id="currentPrice" name="currentPrice" style="width: 60px;"/><br />
					<!--  佣金：
					<input class="text-input " type="text" id="commission" name="commission" style="width: 60px;"/>%<br />
					发布日期：
					<input class="text-input " type="text" id="publishDate" name="publishDate" onClick="WdatePicker()"/>-->
					商品排序：
					<input class="text-input " type="text" id="sort" name="sort" value="1"/><br />
					<!--  已售数量：
					<input class="text-input " type="text" id="saledNum" name="saledNum" value=""/><br />-->
					<span id="taobao_img_span">
					</span>
					
					<input id="comefrom" name="comefrom" type="hidden" value="2" />
					<input id="contentID" name="contentID" type="hidden" value="" />
					<div style="clear: both;height: 1px;background-color: #D5D5D5;margin: 10px 0;"></div>
					
					<input class="button" type="submit" value="修改" id="taobao_item_subm"/>
					<a href="javascript:void(0);" onclick="$(this).parents('#facebox').hide().siblings('#facebox_overlay').remove();">关闭</a>
				</fieldset>
			</form>
		</div>
		<!-- End #messages -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<!-- Page Head -->
			<!-- <h2>欢迎使用<span style="color:red;">返还网商品</span>管理后台</h2> -->
			<!-- <p id="page-intro" style="color: red;">通告：从2013-04-01起，一个淘宝商品只能由一个责任编辑录用。之后其他人已不能添加</p>
			-->
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box 
				<div class="content-box-header">
					<h3><?php echo WHAT;?>列表</h3>
					
					<div class="clear"></div>
				</div>-->
				<!-- End .content-box-header -->
				<div class="content-box-content">
				  <div>
				   <div style="padding: 10px;background-color: #E4E4E4;">
					<form method="get" action="" id="goodssearch">
						专题：
						<select id="zhuantiID" name="zhuantiID" style="width: 80px;">
							<option value="" ></option>
							<?php foreach ($zhuantiList as $keyX=>$itemX):?>
							<option value="<?php echo $itemX['id'];?>" <?php if($_GET['zhuantiID']==$itemX['id']) echo 'selected="selected"';?>><?php echo $itemX['title'].' '.$itemX['startTime'].'至'.$itemX['endTime'];?></option>
							<?php endforeach;?>
						</select>
						&nbsp;&nbsp;&nbsp;
						商品ID：<input class="text-input" type="text" id="goodsid" name="goodsid" value="<?php echo $_GET['goodsid'];?>" size="12"/>
						&nbsp;&nbsp;&nbsp; 
						每页<input class="text-input" id="pagesize" name="pagesize" type="text" value="<?php echo $pagesize;?>" style="width: 25px;"/>条
						&nbsp;&nbsp;&nbsp;
						
						<input type="hidden" id="cateid" name="cateid" value="<?php echo $_GET['cateid'];?>"/>
						<button class="button" id="zhixing" type="submit">搜索</button>
					</form>
				   </div>
					<!-- 
					今日上架<br />
					<a href="?startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>">全部</a>(<?php echo $todayGoodsNum;?>)
					<?php foreach ($category as $item):?>&nbsp;&nbsp;&nbsp;
						<?php if ($item['id']==$_GET['cateid']) : echo $item['cate'].'('.$item['num'].')';else:?>
						<a href="<?php echo $url4;?>&cateid=<?php echo $item['id'];?>&startTime=<?php echo date("Y-m-d");?>&endTime=<?php echo date("Y-m-d");?>"><?php echo $item['cate'].'('.$item['num'].')';?></a>
						<?php endif;endforeach;?> -->
				  </div>
					<div class="clear"></div>
					<div class="tab-content default-tab" id="tab1">
						<!-- This is the target div. id must match the href of this div's tab -->

						<table>
							<thead>
								<tr>
									<td colspan="18">
										<div class="bulk-actions align-left">
										    <button class="button addZhuanti" >添加节日专题</button> ||| <button class="button delZhuanti" >删除节日专题</button>
											<!-- 添加节日专题   zhuantiTitle startTime endTime -->
    											<form method="post" action="?act=insertZhuanti" style="display: none;" id="addZhuantiForm">
    											         专题名称：<input class="text-input" type="text" id="zhuantiTitle" name="zhuantiTitle" value="" size="12" />
    											          时间：
    						                        <input class="text-input" type="text" onClick="WdatePicker()" id="startTime3" name="startTime" size="10"/> 
    						                       -
    						                        <input class="text-input" type="text" onClick="WdatePicker()" id="endTime3" name="endTime" size="10"/>
    						                        <button class="button" id="zhixing" type="submit">添加</button>
    											</form>
    										<!-- 删除节日专题 -->
    										    <form method="post" action="?act=delZhuanti" style="display: none;" id="delZhuantiForm">
    											         专题名称：
    											    <select id="zhuantiIDforDel" name="zhuantiID" style="width: 80px;">
                            							<option value="" ></option>
                            							<?php foreach ($zhuantiList as $keyX=>$itemX):?>
                            							<option value="<?php echo $itemX['id'];?>" ><?php echo $itemX['title'].' '.$itemX['startTime'].'至'.$itemX['endTime'];?></option>
                            							<?php endforeach;?>
                            						</select>
    						                        <button class="button" id="zhixing" type="submit">删除</button>
    											</form>
    										<div class="clear" style="border-bottom: solid 1px #ddd;"></div>
											<button class="button piliangshanchu" >批量删除</button> ||| 
											将选中项设置为专题
											        <select id="SetZhuantiID" name="SetZhuantiID" style="width: 80px;">
                            							<option value="" ></option>
                            							<?php foreach ($zhuantiList as $keyX=>$itemX):?>
                            							<option value="<?php echo $itemX['id'];?>" ><?php echo $itemX['title'].' '.$itemX['startTime'].'至'.$itemX['endTime'];?></option>
                            							<?php endforeach;?>
                            						</select>
											<button class="button piliangSetZhuanTi" >批量设置节日专题</button> 
											
										</div>
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div> 
										<?php endif;?>
										<!-- End .pagination -->
										<div class="clear" style="border-bottom: solid 1px #ddd;"></div>
									</td>
								</tr>
							</thead>
							<thead>
								<tr >
									<th><input class="check-all" type="checkbox" value="-1"/></th>
									<th style="display: none;">编号</th>
									<th style="width: 80px;" class="taobao_url_css">商品ID</th>
									<th style="width: 50px;">图片</th>
									<th style="">标题</th>
									<th style="width: 40px;">原价</th>
									<th style="width: 40px;">现价</th>
									<th style="width: 40px;">已售</th>
									<th style="width: 40px;">排序</th>
									<th style="width: 50px;">专题</th>
									<th style="width: 40px;">点击</th>
									<th style="width: 40px;">操作</th>
								</tr>

							</thead>

							<tbody>
							<?php if(count($pictures)>0):?>
							<?php foreach ($pictures as $key=>$item):$goodsIDs.=$item['goodsID'].',';?>
								<tr goodsid="<?php echo $item['goodsID'];?>" data-id="<?php echo $item['id'];?>">
									<td ><input type="checkbox" name="picSel" value="<?php echo $item['id'];?>"/></td>
									<td style="display: none;"><?php echo $item['id'];?></td>
									<td><a href="<?php echo $item['goodsUrl'];?>" target="_blank"><?php echo $item['goodsID'];?></a></td>
									<td>
										<p><a class="group-pic" href="<?php if($item['comefrom']==2) echo "http://app100656353.imgcache.qzoneapp.com/app100656353/goodsimg/".$item['publishDate']."/".$item['goodsID'].".jpg";else echo '../'.$item['picture'];?>">
											<img src="<?php if($item['comefrom']==2) echo "http://app100656353.imgcache.qzoneapp.com/app100656353/goodsimg/".$item['publishDate']."/".$item['goodsID'].".jpg";else echo '../'.$item['picture'];?>" onerror="this.src='<?php if($item['comefrom']==2) echo $item['picture']; else echo '../'.$item['picture'];?>'" alt="" width="50px;" height="50px;"/>
										</a></p>
									</td>
									<td title=""><?php echo $item['title'];?></td>
									<td><?php echo $item['originalPrice'];?></td>
									<td><?php echo $item['currentPrice'];?></td>
									<td><?php echo $item['saledNum'];?></td>
									<td><?php echo $item['sort'];?></td>
									<td class="tdForZhuanTi"><?php echo $item['ktitle'];?></td>
									<td><?php echo $item['clickNum'];?></td>
									<td>
										<!-- Icons --> 
										<a  title="Edit" class="editbutton" id="<?php echo $item['id'];?>" style="cursor: pointer;">修改</a> <br /><br />
										<a  title="Del" class="delbutton" data-id="<?php echo $item['id'];?>" style="cursor: pointer;">删除</a><br /><br />
										<a  title="Sale" class="isSalebutton" data-id="<?php echo $item['id'];?>" data-status=<?php echo $item['status'];?> style="cursor: pointer;<?php if($item['status']==2) echo 'color: black;';?>"><?php if($item['status']==1) echo '上架中';if($item['status']==2) echo '下架中';?></a>
										<!-- <a href="#" title="Edit Meta"><img src="resources/images/icons/hammer_screwdriver.png" alt="Edit Meta" /></a> -->
									</td>
								</tr>
							<?php endforeach;?>
							<?php else:?>
								<tr style="font-size: 50px;text-align: center; font-weight: bold;"><td colspan="9" style="text-align: center;">没有<?php echo WHAT;?></td></tr>
							<?php endif;?>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="18">
										<div class="bulk-actions align-left">
											<button class="button piliangshanchu" >批量删除</button>
										</div>
										<?php if($maxPage>0):?>
										<div class="pagination">
											<a href="<?php echo $url;?>&page=1" title="First Page">&laquo; First</a>
											<a href="<?php echo $url."&page=".$pageInfo['previous'];?>" title="Previous Page">&laquo; Previous</a>
											<?php foreach ($pages as $item):?> 
											<a href="<?php echo $url."&page=".$item;?>" class="number <?php if($item == $page) echo 'current';?>" title="<?php echo $item;?>"><?php echo $item;?></a>
											<?php endforeach;?>
											<a href="<?php echo $url."&page=".$pageInfo['next'];?>" title="Next Page">Next &raquo;</a>
											<a href="<?php echo $url."&page=".$maxPage;?>" title="Last Page">Last &raquo;</a>
											total : <?php echo $maxPage;?>
										</div>
										<?php endif;?>
										<!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>

						</table>

					</div>
					<!-- End #tab1 -->


				</div>
				<!-- End .content-box-content -->

			</div>
			<!-- End .content-box -->

			<div class="clear"></div>

			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
					&#169; Copyright 2009 Your Company | Powered by 
					<a href="http://themeforest.net/item/simpla-admin-flexible-user-friendly-admin-skin/46073">Simpla Admin</a> | <a href="#">Top</a>
				</small>
			</div>
			<!-- End #footer -->

		</div>
		<!-- End #main-content -->

	</div>
	<?php echo 'http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='.rtrim($goodsIDs,',').'&starttime='.$_GET['startTime'].'&callback=?';?>
<script type="text/javascript">
$(function($) {
	$.getJSON("<?php echo 'http://42.96.169.153:5001/CountHandle.ashx?type=3&product_id='.rtrim($goodsIDs,',').'&starttime='.$_GET['startTime'].'&callback=?';?>", function(data){
		//alert(data.Msg+data.Code);
		var obj = jQuery.parseJSON(data.Msg);
		$.each(obj, function(i,item){
			$("tr[goodsid='"+item.ProductId+"']").children(".clickNum").text(item.Count);
		});
	});
});
</script>
</body>
<!-- Download From www.exet.tk-->
</html>
